#define ERROR 
template<typename T>
class RefPtr
{
	T *ptr;
	unsigned int pCount;
	void del(){
		if(--pCount == 0){
			printf("del ptr:0x%x\n",ptr);
			delete ptr;
		}
	}
public:
	RefPtr(T*p,int n){}
	RefPtr(T*p=0):ptr(p),pCount(1){ }
	RefPtr(const RefPtr &src):ptr(src.ptr),pCount(src.pCount){
	//	printf("do %d+1\n",pCount);
		++pCount;
	}
	void show(){
		printf("ptr:0x%x, do:%d\n",ptr,pCount);
	}
	RefPtr &operator=(const RefPtr &s){
		++s.pCount;
		del();
		ptr = s.ptr;
		pCount = s.pCount;
		return *this;
	}
	T *operator->(){
		if(ptr)return ptr;
		ERROR("access NULL pointer1");
	}
	const T*operator->()const{
		if(ptr)return ptr;
		ERROR("access NULL pointer2");
	}
    
	T &operator*(){
		if(ptr)return *ptr;
		ERROR("access NULL pointer3");
	}
	const T &operator*()const{
		if(ptr)return *ptr;
		ERROR("access NULL pointer4");
	}
	~RefPtr(){
		del();
	 //   INFO("ok\")
	}
};

int main()
{
	return 0;
}